package com.mes.cloud.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.mes.cloud.dao.BmeBcCodeDAO;
import com.mes.cloud.dto.BmeBcCodeDTO;
import com.mes.cloud.service.BmeBcCodeService;
import com.mes.cloud.util.CommPager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
* 编码配置
* @author wxm
* @Time 2020-4-9
*/
@Service
public class BmeBcCodeServiceImpl implements BmeBcCodeService {
    @Autowired
    private BmeBcCodeDAO bmeBcCodeDAO;

    @Override
    public List<BmeBcCodeDTO> findList(Map<Object, Object> condition) {
        return bmeBcCodeDAO.findList(condition);
    }

    @Override
    public long getCount(Map<Object, Object> condition) {
        return bmeBcCodeDAO.getCount(condition);
    }

    @Override
    public long insert(BmeBcCodeDTO bmeBcCodeDTO) {
        return bmeBcCodeDAO.insert(bmeBcCodeDTO);
    }

    @Override
    public long update(BmeBcCodeDTO bmeBcCodeDTO) {
        return bmeBcCodeDAO.update(bmeBcCodeDTO);
    }

    @Override
    public long delete(Integer id) {
        return bmeBcCodeDAO.delete(id);
    }

    @Override
    public BmeBcCodeDTO get(Integer id) {
        return bmeBcCodeDAO.get(id);
    }

    @Override
    public CommPager<BmeBcCodeDTO> findPageList(Map<Object, Object> condition) {
        int pageIndex = condition.get("pageIndex") == null ? 0 : Integer.valueOf(condition.get("pageIndex").toString());
        int pageSize = condition.get("pageSize") == null ? 10 : Integer.valueOf(condition.get("pageSize").toString());
        Page<BmeBcCodeDTO> page = PageHelper.startPage(pageIndex, pageSize, true);
        List<BmeBcCodeDTO> dictList = bmeBcCodeDAO.findList(condition);
        CommPager<BmeBcCodeDTO> pageResult = new CommPager<>(page, dictList);
        return pageResult;
    }

}
